package com.ruoyi.service.domain;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Random;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import javax.validation.constraints.NotNull;

import com.ruoyi.common.utils.DateUtils;
import lombok.Data;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 收费记录对象 service_charge
 * 
 * @author yepanpan
 * @date 2025-04-21
 */
@Data
public class ServiceCharge extends BaseEntity
{
    public static final String TYPE_ROOM = "room";
    public static final String TYPE_CAR = "car";
    public static final String TYPE_DEPOSIT = "deposit";
    public static final String TYPE_TENANCY = "tenancy";

    private static final long serialVersionUID = 1L;

    /** 自增长主键ID */
    private Long id;

    /** 单号 */
    @Excel(name = "单号")
    private String num;

    /** 区域 */
    @Excel(name = "区域")
    private String deptName;
    @NotNull
    private Long deptId;

    /** 房屋 */
    private Long roomId;

    @Excel(name = "楼栋")
    private String buildingName;
    /** 房屋 */
    @Excel(name = "单元号")
    private Integer unitNum;
    @Excel(name = "房屋")
    private String roomName;

    /** 车辆 */
    @Excel(name = "车辆")
    private String carPlate;
    private Long carId;

    /** 收费项目 */
    @Excel(name = "收费项目", dictType = "fee_type")
    @NotNull
    private String feeType;

    /** 收费标准 */
    @Excel(name = "收费标准")
    private String itemName;
    private Long itemId;

    /** 折扣 */
    @Excel(name = "折扣")
    private String discountName;
    private Long discountId;

    /** 缴费月数 */
    @Excel(name = "缴费月数")
    private BigDecimal feeMonth;

    /** 应收金额 */
    @Excel(name = "应收金额")
    @NotNull
    private BigDecimal feeShould;

    /** 实收金额 */
    @Excel(name = "实收金额")
    @NotNull
    private BigDecimal feeReal;

    /** 退费金额 */
    @Excel(name = "退费金额")
    private BigDecimal feeReturn;

    /** 支付方式 */
    @Excel(name = "支付方式", dictType="pay_way", comboReadDict=true)
    @NotNull
    private String payWay;

    /** 开始日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "开始日期", width = 30, dateFormat = "yyyy-MM-dd")
    @NotNull
    private Date startDate;

    /** 结束日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "结束日期", width = 30, dateFormat = "yyyy-MM-dd")
    @NotNull
    private Date endDate;

    /** 收费单状态 */
    @Excel(name = "收费单状态", dictType="charge_status", comboReadDict=true)
    @NotNull
    private String status;


    public void genNum(){
        if(num == null){
            num = DateUtils.dateTimeNow("yyyyMMddHHmmss")+String.format("%02d", new Random().nextInt(10));
        }
    }
}
